<?php
    $page_title = 'สถาบันภาษา BV Language : แนะนำ ติชม';
    include('header.php');
    $sql = "SELECT td_value FROM text_data WHERE td_id=33 OR td_id=34 ORDER BY td_id";
    $result = $db->Execute($sql);
    
    while (!$result->EOF)
    {
	$data[] = $result->fields['td_value'];
	$result->MoveNext();
    }
    
    
    // PAGE LIMIT
    if(isset($_GET['p'])){
	$page = $_GET['p'];
    }else{
	$page = 1;
    }
    
    $sql_relate = "SELECT * FROM personnels WHERE p_active=1 ORDER BY p_id DESC";
    
    $page_limit = 5;
    $grouplimit = 10;
    $start_row = (($page-1))*$page_limit;
    $sql_relate_nolimit = $sql_relate;
    $sql_relate .= " LIMIT $start_row,$page_limit";
    // PAGE LIMIT END

    // PAGE LIMIT
    $count_row = $db->Execute($sql_relate_nolimit);
    $count_row2 = $count_row->NumRows();
    $count_row3 = ceil($count_row2/$page_limit) ;
    
    $limitlink = '';
    if($count_row3>1)
    {
	if($count_row3<$grouplimit)
	{
	    for($i = 1 ; $i<=$count_row3 ; $i++) {
		if($i==$page){
		    $limitlink .= $i."&nbsp;";
		}else{
		    $limitlink .= "<a href='personnel.php?p=$i#newspage'>&nbsp;$i&nbsp;</a>&nbsp;";
		}
	    }
	}
	else
	{
	    $pagegroup = ceil($page/$grouplimit); // Find group of current page
	    $allpagegroup = ceil($count_row3/$grouplimit); // Total page group
	    if($pagegroup==1) // If First Group
	    {
		if($page>1)
		{
		    $limitlink .= "<a href='personnel.php?p=".($page-1)."#newspage' title='Previous Page'>&nbsp;<&nbsp;previous&nbsp;</a>&nbsp;";
		}
		$i=($pagegroup*$grouplimit)-($grouplimit-1);
		$j=($pagegroup*$grouplimit);
		for($i ; $i<=$j ; $i++) {
		    if($i==$page){
			$limitlink .= $i."&nbsp;";
		    }else{
			$limitlink .= "<a href='personnel.php?p=$i#newspage'>&nbsp;$i&nbsp;</a>&nbsp;";
		    }
		}
		$limitlink .= "...&nbsp;<a href='personnel.php?p=".($page+1)."#newspage' title='Next Page'>&nbsp;next&nbsp;>&nbsp;</a>&nbsp;";
		$limitlink .= "<a href='personnel.php?p=$count_row3#newspage' title='Last Pages'>&nbsp;last&nbsp;>>&nbsp;</a>&nbsp;";
	    }
	    else if($pagegroup==$allpagegroup) // If Last Group
	    {
		$limitlink = "<a href='personnel.php?p=1#newspage' title='First Pages'>&nbsp;<<&nbsp;first&nbsp;</a>&nbsp;";
		$limitlink .= "<a href='personnel.php?p=".($page-1)."#newspage' title='Previous Page'>&nbsp;<&nbsp;previous&nbsp;</a>&nbsp;...&nbsp;";
		$i=($pagegroup*$grouplimit)-($grouplimit-1);
		$j=$count_row3;
		for($i ; $i<=$j ; $i++) {
		    if($i==$page){
			$limitlink .= $i."&nbsp;";
		    }else{
			$limitlink .= "<a href='personnel.php?p=$i#newspage'>&nbsp;$i&nbsp;</a>&nbsp;";
		    }
		}
		if($page<$count_row3)
		{
		    $limitlink .= "&nbsp;<a href='personnel.php?p=".($page+1)."#newspage' title='Next Page'>&nbsp;next&nbsp;>&nbsp;</a>&nbsp;";
		    $limitlink .= "<a href='personnel.php?p=$count_row3#newspage' title='Last Pages'>&nbsp;last&nbsp;>>&nbsp;</a>&nbsp;";
		}
	    }
	    else
	    {
		$limitlink = "<a href='personnel.php?p=1#newspage' title='First Pages'>&nbsp;<<&nbsp;first&nbsp;</a>&nbsp;";
		$limitlink .= "<a href='personnel.php?p=".($page-1)."#newspage' title='Previous Page'>&nbsp;<&nbsp;previous&nbsp;</a>&nbsp;...&nbsp;";
		$i=($pagegroup*$grouplimit)-($grouplimit-1);
		$j=($pagegroup*$grouplimit);
		for($i ; $i<=$j ; $i++) {
		    if($i==$page){
			$limitlink .= $i."&nbsp;";
		    }else{
			$limitlink .= "<a href='personnel.php?p=$i#newspage'>&nbsp;$i&nbsp;</a>&nbsp;";
		    }
		}
		$limitlink .= "...&nbsp;<a href='personnel.php?p=".($page+1)."#newspage' title='Next Page'>&nbsp;next&nbsp;>&nbsp;</a>&nbsp;";
		$limitlink .= "<a href='personnel.php?p=$count_row3#newspage' title='Last Pages'>&nbsp;last&nbsp;>>&nbsp;</a>&nbsp;";
	    }
	}
    }
    
    //echo $limitlink;
    
    $result = $db->Execute($sql_relate);
    $news_list = '';
    $i = 1;
    while (!$result->EOF)
    {
	if(file_exists($iniVars['Locations']['sitepath'].$result->fields['p_img']) AND ($result->fields['p_img']!=NULL AND $result->fields['p_img']!=''))
	{
	    $news_img = $iniVars['Locations']['siteurl'].$result->fields['p_img'];
	}
	else
	{
	    $news_img = $iniVars['Locations']['siteurl'].'images/bvk_logo.jpg';
	}
	
	$news_msg = nl2br($result->fields['p_msg']);
	
	if($i%2){
	    $boxclass = '';
	}else{
	    $boxclass = ' personnel_box_01_nobg';
	}
	
	$news_list .= <<<sdl
		<div class="personnel_box_list">
                    <div class="personnel_box_list_flag">
                        <img src="images/personnel_box_list_flag_th.jpg" />
                        <img src="images/personnel_box_list_flag_jp.jpg" />
                        <img src="images/personnel_box_list_flag_ge.jpg" />
                        <img src="images/personnel_box_list_flag_ch.jpg" />
                    </div>
                    <div class="personnel_box_list_img">
                        <img src="{$news_img}" />
                    </div>
                    <div class="personnel_box_01 personnel_box_list_msg{$boxclass}">
                        <div class="personnel_box_list_msg_">
                            {$news_msg}
                        </div>
                    </div>
                    <div class="clear">&nbsp;</div>
                </div>
sdl;
	$i++;
	$result->MoveNext();
    }
    
    
    require_once('search.php');
?>
	    <div id="personnel" class="main_content">
                
		<div id="personnel_top_left">
                    <img src="images/personnel_top_left.jpg" />
                </div>
		<div id="personnel_top_right">
                    <div class="personnel_box_01">
                        <p class="personnel_box_title" id="personnel_box_title_01">เรียน ท่านผู้บริหารทุกท่าน</p>
                        <p class="personnel_box_msg">
                            ด้านล่างนี้คือบุคลากรที่มีความรู้ความสามารถด้านภาษาต่างประเทศ ซึ่งส่วนใหญ่เป็น
นักเรียนของสถาบัน ที่กำลังอยู่ในระหว่างการหางาน ทางสถาบันภาษา <span class="text_color16">BV</span>&nbsp;<span class="text_color15">Language</span> ได้ทำการทดสอบ
ความสามารถทางภาษา รวมถึงรวบรวมประวัติการศึกษา และประวัติการทำงานต่างๆ เพื่ออำนวยความ
สะดวกให้ท่านได้รับบุคลากรที่ตรงกับความต้องการมากที่สุด หากท่านสนใจและต้องการติดต่อกับ
ผู้สมัครคนใดเพื่อทำการนัดสัมภาษณ์ กรุณาแจ้งกับทางสถาบันที่ <?php echo nl2br($data[0]); ?>
                        </p>
                        <p class="personnel_box_thank">ขอขอบคุณทุกท่านที่ได้ให้โอกาสนักเรียนของเราในการสมัครงาน</p>
                    </div>
                    <div class="personnel_box_02">
                        <p class="personnel_box_title" id="personnel_box_title_02">Dear Human Resource Department</p>
                        <p class="personnel_box_msg">
                            The followings are job applicants that <span class="text_color16">BV</span>&nbsp;<span class="text_color15">Language</span> Institute has selected 
for your vacant positions. These candidates, mainly our current students, have been 
in our monthly language training courses and experienced our institute’s basic 
tests of language skills to make sure that they are the most appropriate one for 
your organizational needs. If you are interested in any personals, please feel 
free to contact us at <?php echo nl2br($data[1]); ?>
                        </p>
                        <p class="personnel_box_thank">Thank you for granting an opportunity to our students.</p>
                    </div>
                </div>
                <div class="clear">&nbsp;</div>
                
                <div id="personnel_bottom_line">&nbsp;</div>
                
                <?php echo $news_list; ?>
		<div id="personnel_list_nav">
		    <?php echo $limitlink; ?>
		</div>
            </div>
            <!-- class main_content -->
<?
    include('footer.php');
?>